﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
#if SILVERLIGHT
using System.Windows.Browser;
#else
using System.Diagnostics;
#endif

namespace P2.Cuberry.Modules.Framework.WPFCharting
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            // Create distinct brushes for the different sample categories
            var chartingBrush = new SolidColorBrush(Color.FromArgb(255, 255, 220, 220));


            // Populate the list of samples
            DataContext = new List<DemoItem>
            {
                new DemoItem { Title = "Charting Introduction", Control = new ChartingIntroduction(), Background = chartingBrush },
                new DemoItem { Title = "Chart Styling", Control =  new ChartStyling(), Background = chartingBrush},
                new DemoItem { Title = "Columns With Color", Control = new ColumnsWithColor(), Background = chartingBrush },
                new DemoItem { Title = "Dynamic Pie Gradients", Control = new DynamicPieGradients(), Background = chartingBrush},
                new DemoItem { Title = "Inverted Axis", Control = new InvertedAxis(), Background = chartingBrush },
                new DemoItem { Title = "Letter Frequency", Control = new LetterFrequency(), Background = chartingBrush },
            };
        }

        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Referenced by XAML.")]
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Swap in a new sample
            SampleContainer.Children.Clear();
            //PostList.ItemsSource = null;
            if ((null != e.AddedItems) && (0 < e.AddedItems.Count))
            {
                var demoItem = (DemoItem)e.AddedItems[0];
                SampleContainer.Children.Add(demoItem.Control);
                //PostList.ItemsSource = demoItem.Posts;
            }
        }

        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Referenced by XAML.")]
        private void UriMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //// Navigate to the specified web page
            //var textBlock = (TextBlock)sender;
            //var uri = textBlock.Tag as Uri ?? new Uri(textBlock.Tag as string ?? textBlock.Text);
            //Process.Start(uri.ToString());
        }


    }
}
